|
|
|
|
|
|
|
Setting Up the Main Items |
|
|
|
|
|
|
|
|
After deciding what functions to include in your menu and how to group these functions, you can then build the menu. To create a menu, first open the form on which you want the menu located, and then start the Menu Editor in any of three ways: click the Menu Editor button on the toolbar; choose Tools, Menu Editor; or press Ctrl+E. The Menu Editor then appears, as shown in Figure 6.3. |
|
|
|
|
|
|
|
|
Figure 6.3
The Menu Editor provides an easy
way to create menus for your program. |
|
|
|
|
|
|
|
|
Each line of text (menu item) in a menu is a Menu control, just as each command button that you place on a form is a CommandButton control. You use the Menu Editor to create Menu controls and to set the following properties for each control: |
|
|
|
|
|
|
|
|
Caption. The caption is the actual text that is displayed in the menu item. You can specify an access key, which allows the users to select the menu item with the keyboard instead of a mouse, by placing an ampersand (&) before the appropriate letter of the caption. For example, if a particular menu item's Caption property is set to F&ormat, the "o" is underlined, and the users can select that item by pressing O when the menu is active. The Caption property is required for all menu items. |
|
|
|
|
|
|
|
|
Name. This property is used to identify the menu item in code. The Name property is required for all menu items. Like all other controls, each Menu control must have a name that will be used to refer to it in code. With these controls, unlike other controls, however, Visual Basic does not give menu items a default name; therefore, you must set the Name property of all menu items before leaving the Menu Editor. |
|
|
|
|
|
|
|
|
Index. If this menu item is part ofcontrol array, the Index property uniquely identifies the particular control array element. |
|
|
|
|
|
|
|
|
Shortcut. With this property, you can define shortcut key combinations that allow your users to select a menu item with one keystroke, bypassing the menu system entirely. For example, many programs use Ctrl+P as a shortcut key, eliminating the need to choose File, Print from the menu system. |
|
|
|
|
|